package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpToolsUDFNewFormPageUtil extends SeleniumPageUtil {
	public final static By TNF_LINK_SAVE = By.id("FormEdit1_btnSave");
	public final static By TNF_LINK_CLOSE = By.id("FormEdit1_btnDone");
	public final static By TNF_SPAN_HEADER = By.id("FormEdit1_lblHdr");
	public final static By TNF_TD_BASED_ON_UDF_TEMPLATE = By.xpath("//*[@id='form1']/table/tbody/tr/td/div/table[2]/tbody/tr[1]/td[1]");
	public final static By TNF_SELECT_BASED_ON_UDF_TEMPLATE = By.id("FormEdit1_cboDefaultUdfID");
	public final static By TNF_TD_FORM_NAME = By.xpath("//*[@id='form1']/table/tbody/tr/td/div/table[2]/tbody/tr[2]/td[1]");
	public final static By TNF_INPUT_FORM_NAME = By.id("FormEdit1_txtudfName");
	public final static By TNF_TD_COMMENT = By.xpath("//*[@id='form1']/table/tbody/tr/td/div/table[2]/tbody/tr[3]/td[1]");
	public final static By TNF_TEXTAREA_COMMENT = By.id("FormEdit1_txtComment");
	public final static By TNF_TD_CROSSTAB_GRID = By.xpath("//*[@id='form1']/table/tbody/tr/td/div/table[2]/tbody/tr[4]/td[1]");
	public final static By TNF_INPUT_CROSSTAB_GRID = By.id("FormEdit1_chkCrosstabFlag");
	public final static By TNF_TD_REPEAT = By.xpath("//*[@id='form1']/table/tbody/tr/td/div/table[2]/tbody/tr[4]/td[3]");
	public final static By TNF_INPUT_REPEAT = By.id("FormEdit1_chkRepeatFlag");
	
	public static void enterToolsNewFormPage(){
		SpToolsUDFDefaultPageUtil.enterToolsUserDefinedFormsPage();
		SeleniumUtil.click(SeleniumUtil.getCachedElement(SpToolsUDFDefaultPageUtil.TUDF_LINK_NEW_FORM));
		waitForPageToLoad();
	}
	
	public static void waitForPageToLoad(){
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.selectFrame(SpHomePageUtil.HOME_FRAME_CONTENT_NAME);
		SeleniumUtil.waitOnElements(new By[]{
				TNF_LINK_SAVE, TNF_LINK_CLOSE, TNF_SELECT_BASED_ON_UDF_TEMPLATE
			});
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(TNF_LINK_SAVE));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(TNF_LINK_CLOSE));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(TNF_SELECT_BASED_ON_UDF_TEMPLATE));
	}
}
